//
//  PersonalViewController.m
//  PaiQuan
//
//  Created by Mac on 16/7/12.
//  Copyright © 2016年 huigu. All rights reserved.
//

#import "PersonalViewController.h"
#import "addMoreController.h"

@interface PersonalViewController ()<UIScrollViewDelegate>
@property(nonatomic,strong)UIScrollView *scrollView;
@property(nonatomic,strong)UIView *topView;
@property(nonatomic,strong)NSArray *achievementArr;
@property(nonatomic,strong)NSArray *joinClubArr;
@end

@implementation PersonalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH)];
    
    self.scrollView.backgroundColor = PQ_COLOR_LightGray;
    self.scrollView.contentSize = CGSizeMake(ScreenW, ScreenH+RATIO(100));
     self.scrollView.bounces = YES;
    // 是否分页
    self.scrollView.pagingEnabled = NO;
    // 是否滚动
    self.scrollView.delegate = self;
    self.scrollView.showsVerticalScrollIndicator = NO;
    
    [self.view addSubview:self.scrollView];
    
    
    
    self.titleView.title = @"名片";
    [self.titleView.btnBack setImage:PQIMG(@"back") forState:UIControlStateNormal];
    [self.titleView.btnBack setTitle:@"返回" forState:UIControlStateNormal];
    [self.titleView.btnBack setTitleColor:PQ_COLOR_YELLOW forState:UIControlStateNormal];
    
    [self.titleView.rightBtn setTitle:@"更多" forState:UIControlStateNormal];
    [self.titleView.rightBtn setTitleColor:PQ_COLOR_YELLOW forState:UIControlStateNormal];
    [self.titleView.rightBtn addTarget:self action:@selector(rightBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
    [self setUPUI];
}
#pragma mark --按钮的点击事件
-(void)rightBtnDidClick{
    addMoreController *addMoreVC = [[addMoreController alloc] init];
    [self.navigationController pushViewController:addMoreVC animated:YES];
    
    
}
-(void)setUPUI{
    
    
    
    //顶部试图部门
    self.topView = [[UIView alloc] init];
    self.topView.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:self.topView];
    self.topView.frame = CGRectMake(0, 24+NaviBarHeight, ScreenW, RATIO(196));
       //头像
    UIImageView *headerView = [[UIImageView alloc] init];
    [self.topView addSubview:headerView];
    headerView.image =PQIMG(@"headerview");
    headerView.layer.cornerRadius =	RATIO(18);
    headerView.layer.masksToBounds = YES;
    headerView.frame = CGRectMake(RATIO(24), RATIO(24), RATIO(144), RATIO(144));
    //形容的label
    UILabel *describeLabel = [[UILabel alloc ] init];
    describeLabel.text = @"战无不胜的";
    describeLabel.textColor =PQ_COLOR_MIDGray;
    describeLabel.font = FONT(13);
    [self.topView addSubview: describeLabel];
    
   [describeLabel makeConstraints:^(MASConstraintMaker *make) {
       make.left.equalTo(headerView.right).offset(RATIO(56));
       make.top.equalTo(self.topView.top).offset(RATIO(32));
   }];
    //名字的label
    UILabel *nameLabel = [[UILabel alloc ] init];
    nameLabel.text = @"隐匿的偷窥者";
    nameLabel.textColor =PQ_COLOR_BLACK;
    nameLabel.font = FONT(18);
    [self.topView addSubview: nameLabel];
    
    [nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(headerView.right).offset(RATIO(56));
        make.top.equalTo(describeLabel.bottom).offset(RATIO(20));
    }];
    
    UILabel *explainLabel = [[UILabel alloc ] init];
    explainLabel.text = @"我不会随便偷窥的.";
    explainLabel.textColor =PQ_COLOR_MIDGray;
    explainLabel.font = FONT(12);
    [self.topView addSubview: explainLabel];
    
    [explainLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(headerView.right).offset(RATIO(56));
        make.top.equalTo(nameLabel.bottom).offset(RATIO(24));
    }];
//
    UILabel *sexLabel = [[UILabel alloc ] init];
    sexLabel.text = @"男";
    sexLabel.textColor = [UIColor whiteColor];
    sexLabel.font = FONT(18);
    sexLabel.layer.cornerRadius = 9;
    sexLabel.layer.masksToBounds = YES;
    sexLabel.backgroundColor = PQ_COLOR_MIDGray;
    [self.topView addSubview: sexLabel];

    [sexLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameLabel.right).offset(RATIO(20));
        make.centerY.equalTo(nameLabel);
        make.width.equalTo(RATIO(36));
    }];
// 生涯战况
    UILabel *gradeLabel = [[UILabel alloc] init];
    gradeLabel.text = @"生涯战况";
    gradeLabel.textColor = PQ_COLOR_BLACK;
    gradeLabel.font = FONT(16);
    gradeLabel.backgroundColor = PQ_COLOR_LightGray;
    [self.scrollView addSubview:gradeLabel];
    
    [gradeLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.bottom);
        make.width.equalTo(self.topView.width);
        make.height.equalTo(RATIO(90));
        make.left.equalTo(self.scrollView.left);
    }];
//对局
    UIView *outsiderView = [[UIView alloc] init];
    outsiderView.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:outsiderView];
    [outsiderView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(gradeLabel.bottom);
        make.width.equalTo(self.topView.width);
        make.height.equalTo(RATIO(96));
        make.left.equalTo(self.scrollView.left);

        
    }];
 //对局数
    UILabel *coupletLabel = [[UILabel alloc] init];
    coupletLabel.text = @"对局数";
    coupletLabel.textColor = PQ_COLOR_BLACK;
    coupletLabel.font = FONT(16);
   
    [outsiderView addSubview:coupletLabel];

    [coupletLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(outsiderView.left).offset(RATIO(24));
        make.centerY.equalTo(outsiderView);
    }];

    UILabel *coupletCountLabel = [[UILabel alloc] init];
    coupletCountLabel.text = @"2354场";
    coupletCountLabel.textColor = PQ_COLOR_BLACK;
    coupletCountLabel.font = FONT(16);
    
    [outsiderView addSubview:coupletCountLabel];
    
    [coupletCountLabel makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(outsiderView.right).offset(RATIO(-24));
        make.centerY.equalTo(outsiderView);
    }];
    
//胜率
    UIView *victoryView = [[UIView alloc] init];
    victoryView.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:victoryView];
    [victoryView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(outsiderView.bottom).offset(RATIO(6));
        make.width.equalTo(self.topView.width);
        make.height.equalTo(RATIO(96));
        make.left.equalTo(self.scrollView.left);
        
        
    }];
    UILabel *victoryLabel = [[UILabel alloc] init];
    victoryLabel.text = @"对局数";
    victoryLabel.textColor = PQ_COLOR_BLACK;
    victoryLabel.font = FONT(16);
    
    [victoryView addSubview:victoryLabel];
    
    [victoryLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(victoryView.left).offset(RATIO(24));
        make.centerY.equalTo(victoryView);
    }];
    

    UILabel *vicoryCountLab = [[UILabel alloc] init];
    vicoryCountLab.text = @"32%";
    vicoryCountLab.textColor = PQ_COLOR_BLACK;
    vicoryCountLab.font = FONT(16);
    
    [victoryView addSubview:vicoryCountLab];
    
    [vicoryCountLab makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(victoryView.right).offset(-RATIO(24));
        make.centerY.equalTo(victoryView);
    }];

    // 对方获得的成就
    UILabel * achievementLabel = [[UILabel alloc] init];
    achievementLabel.text = @"对方获得的成就";
    achievementLabel.textColor = PQ_COLOR_BLACK;
    achievementLabel.font = FONT(16);
    achievementLabel.backgroundColor = PQ_COLOR_LightGray;
    [self.scrollView addSubview:achievementLabel];
    
    [achievementLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(victoryView.bottom);
        make.width.equalTo(self.topView.width);
        make.height.equalTo(RATIO(90));
        make.left.equalTo(self.scrollView.left);
    }];
    
    
    //成就view
    UIView *achievementView = [[UIView alloc] init];
    achievementView.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:achievementView];
    [achievementView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(achievementLabel.bottom).offset(RATIO(6));
        make.width.equalTo(self.topView.width);
        make.height.equalTo(RATIO(200));
        make.left.equalTo(self.scrollView.left);
        
        
    }];
    //成就数组
    self.achievementArr = @[@"鬼谷子",@"战无不胜",@"横扫千军"];
    CGFloat leftMargin = RATIO(64);
    CGFloat Margin = RATIO(100);
    CGFloat width =RATIO(72);
    CGFloat height = width;
    for (NSInteger i =0; i<self.achievementArr.count; i++) {
        //成就图片
        UIImageView *achievementImg = [[UIImageView alloc] init];
        achievementImg.backgroundColor = PQ_COLOR_DarkGray;
        achievementImg.layer.cornerRadius = 18;
        achievementImg.layer.masksToBounds = YES;
        
        [achievementView addSubview:achievementImg];
        achievementImg.frame = CGRectMake(leftMargin+(width+Margin)*i, RATIO(28), width, height);
        
        UILabel  *achievementLab = [[UILabel alloc] init];
        achievementLab.text = self.achievementArr[i];
        achievementLab.textColor = PQ_COLOR_BLACK;
        achievementLab.font = FONT(12);
        [achievementView addSubview:achievementLab];
        [achievementLab makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(achievementImg);
            make.top.equalTo(achievementImg.bottom).offset(RATIO(12));
        }];
        
        
        
        
        
        
        
    }
    //对方加入的俱乐部
    
    UILabel * joinClubLabel = [[UILabel alloc] init];
    joinClubLabel.text = @"对方加入的俱乐部";
    joinClubLabel.textColor = PQ_COLOR_BLACK;
    joinClubLabel.font = FONT(16);
    joinClubLabel.backgroundColor = PQ_COLOR_LightGray;
    [self.scrollView addSubview:joinClubLabel];
    
    [joinClubLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(achievementView.bottom);
        make.width.equalTo(self.topView.width);
        make.height.equalTo(RATIO(90));
        make.left.equalTo(self.scrollView.left);
    }];
    UIView *joinClubView = [[UIView alloc] init];
    joinClubView.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:joinClubView];
    [joinClubView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(joinClubLabel.bottom).offset(RATIO(6));
        make.width.equalTo(self.topView.width);
        make.height.equalTo(RATIO(200));
        make.left.equalTo(self.scrollView.left);
        
        
    }];
    //加入俱乐部的数组
    self.joinClubArr = @[@"君道杀拳",@"穿林北腿",@"哈嘛神功"];
   
    for (NSInteger i =0; i<self.joinClubArr.count; i++) {
        //成就图片
        UIImageView *joinImg = [[UIImageView alloc] init];
        joinImg.backgroundColor = PQ_COLOR_DarkGray;
        joinImg.layer.cornerRadius = 18;
        joinImg.layer.masksToBounds = YES;
        
        [joinClubView addSubview:joinImg];
        joinImg.frame = CGRectMake(leftMargin+(width+Margin)*i, RATIO(28), width, height);
        
        UILabel  *joinLabel = [[UILabel alloc] init];
        joinLabel.text = self.joinClubArr[i];
        joinLabel.textColor = PQ_COLOR_BLACK;
        joinLabel.font = FONT(12);
        [joinClubView addSubview:joinLabel];
        [joinLabel makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(joinImg);
            make.top.equalTo(joinImg.bottom).offset(RATIO(12));
        }];
        
        
        
        
        
        
        
    }
    //sendMessageBtn
    
    UIButton *sendMessageBtn = [[UIButton alloc] init];
    
    [sendMessageBtn setTitle:@"发送消息" forState:UIControlStateNormal];
    [sendMessageBtn setTitleColor:PQ_COLOR_YELLOW forState:UIControlStateNormal];
    [sendMessageBtn.titleLabel setFont:FONT(16)];
    [sendMessageBtn setBackgroundColor:PQ_COLOR_BLACK];
    [self.scrollView addSubview:sendMessageBtn];
    
  [sendMessageBtn makeConstraints:^(MASConstraintMaker *make) {
      make.left.equalTo(self.scrollView.left);
      make.top.equalTo(joinClubView.bottom);
      make.width.equalTo(self.scrollView);
      make.height.equalTo(RATIO(98));
  }];
    
    
    


    
    
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
